/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package Configurations;

import java.security.MessageDigest;

/**
 *
 * @author mizheng
 */
public class SALT {
    private static SALT instance = null;
    private SALT(){}
    
    public static SALT getInstance() {
        if (instance == null) {
            instance = new SALT();
        }
        return instance;
    }
    
     public static String encrypt(String password)throws Exception
    {
        MessageDigest md = MessageDigest.getInstance("SHA-256");
        md.update(password.getBytes());
 
        byte byteData[] = md.digest();
 
        //convert the byte to hex format
        StringBuffer sb = new StringBuffer();
        for (int i = 0; i < byteData.length; i++) {
         sb.append(Integer.toString((byteData[i] & 0xff) + 0x100, 16).substring(1));
        }
        
        return sb.toString();
 
    }
    
}
